/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import DAO.DAO_Order;
import Entity.Order;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author DUNGDA
 */
@ManagedBean
@RequestScoped
public class OrderBean {

    
    List<Order> listOrd = new ArrayList<Order>();
    Order order = new Order();
    private int OrderId;
    private String datetime;
    private String ShipAdd;
    private String ReceivedName;
    private String ReceivedPhone;
    private int cusId;
    private float OrderPrice;
    private String CusName;
    private int Status;
    private String Message;

    /** Creates a new instance of OrderBean */
    public OrderBean() {
    }

    public void deleteOrder(int ID) {
        DAO_Order ord = new DAO_Order();
        try {
            ord.deleteOrder(ID);
            setMessage("Delete Success !");
        } catch (Exception ex) {
            ex.printStackTrace();
            setMessage("Delete Error !");
        }

    }

    public List<Order> getOrder1() {
        listOrd = DAO_Order.showOrder();
        return listOrd;
    }

    public void editOrder(int id) {
        DAO_Order ord = new DAO_Order();
        ord.EditOrder(OrderId, datetime, ShipAdd, ReceivedName, ReceivedPhone, getCusId(), Status, getOrderPrice());
    }

    public int getOrderId() {
        return OrderId;
    }

    public void setOrderId(int OrderId) {
        this.OrderId = OrderId;
        //DAO_Order order = new DAO_Order(); 
    }

    public String getDatetime() {
        return datetime;
    }

    public void setDatetime(String datetime) {
        this.datetime = datetime;
    }

    public String getShipAdd() {
        return ShipAdd;
    }

    public void setShipAdd(String ShipAdd) {
        this.ShipAdd = ShipAdd;
    }

    public String getReceivedName() {
        return ReceivedName;
    }

    public void setReceivedName(String ReceivedName) {
        this.ReceivedName = ReceivedName;
    }

    public String getReceivedPhone() {
        return ReceivedPhone;
    }

    public void setReceivedPhone(String ReceivedPhone) {
        this.ReceivedPhone = ReceivedPhone;
    }

    public float getOrderPrice() {
        return OrderPrice;
    }

    public void setOrderPrice(float OrderPrice) {
        this.OrderPrice = OrderPrice;
    }

    public String getCusName() {
        return CusName;
    }

    public void setCusName(String CusName) {
        this.CusName = CusName;
    }

    public int getStatus() {
        return Status;
    }

    public void setStatus(int Status) {
        this.Status = Status;
    }

    public String getMessage() {
        return Message;
    }

    public void setMessage(String Message) {
        this.Message = Message;
    }

    public int getCusId() {
        return cusId;
    }

    public void setCusId(int cusId) {
        this.cusId = cusId;
    }
}
